var Instrument=Win.extend({
		p:null,
		name:null,
		ctor:function (parent,name,tag) {
			this._super(parent,name);
			this.p=parent;
			this.name=name;
			this.setTag(tag);
			this.initSp();
		},
		initSp:function (){
			//电导仪
			var instrument=new Button(this.main,10,TAG_INSTRUMENT,"#equitment/instrument1.png");
			instrument.setPosition(cc.p(this.main.width*0.5,this.main.height*0.5));
			instrument.setVisible(false);
			//电导仪背面
			var instrument1=new Button(this.main,10,TAG_INSTRUMENT_BACK,"#equitment/Instrument_back.png");
			instrument1.setPosition(cc.p(this.main.width*0.5,this.main.height*0.5));
			//插孔
			var socket=new Button(this.main,10,TAG_SOCKET,"#equitment/socket.png");
			socket.setPosition(cc.p(this.main.width*0.69, this.main.height*0.445));
			
			var socket1=new Button(this.main,10,TAG_SOCKET1,"#equitment/socket1.png");
			socket1.setPosition(cc.p(this.main.width*0.45, this.main.height*0.420));
			
			var socket2=new Button(this.main,10,TAG_SOCKET2,"#equitment/socket21.png");
			socket2.setPosition(cc.p(this.main.width*0.381, this.main.height*0.435));
			
			//遮挡
			var instrument_back2=new Button(this.main,11,TAG_INSTRUMENT_BACK2,"#equitment/Instrument_back2.png");
			instrument_back2.setPosition(cc.p(this.main.width*0.496, this.main.height*0.5));
			
			var instrument_back1=new Button(this.main,11,TAG_INSTRUMENT_BACK1,"#equitment/Instrument_back1.png");
			instrument_back1.setPosition(cc.p(this.main.width*0.45, this.main.height*0.5));
			
			var powerline=new Button(this.main,10,TAG_POWERLINE_HEAD,"#equitment/line1.png",this.callback);
			powerline.setPosition(cc.p(this.main.width*0.70, this.main.height*0.3));
			
			var electrode_line=new Button(this.main,10,TAG_ELECTRODE_HEAD,"#equitment/line2.png",this.callback);
			electrode_line.setPosition(cc.p(this.main.width*0.48,this.main.height*0.3));
			electrode_line.setVisible(false);
			

			var electrode_line1=new Button(this.main,10,TAG_ELECTRODE_HEAD1,"#equitment/line3.png",this.callback);
			electrode_line1.setPosition(cc.p(this.main.width*0.42,this.main.height*0.3));
			electrode_line1.setVisible(false);
			
			//按钮
			var onOroff=new Button(this.main,11,TAG_BUTTON_ONOROFF,"#equitment_button/onOroff.png",this.callback);
			onOroff.setPosition(cc.p(this.main.width*0.502,this.main.height*0.473));
			onOroff.setVisible(false);
			
			var unit=new Button(this.main,11,TAG_BUTTON_UNIT,"#equitment_button/Unit.png",this.callback);
			unit.setPosition(cc.p(this.main.width*0.393,this.main.height*0.322));
			unit.setVisible(false);
			
			var cal=new Button(this.main,11,TAG_BUTTON_CAL,"#equitment_button/CAL.png",this.callback);
			cal.setPosition(cc.p(this.main.width*0.375, this.main.height*0.478));
			cal.setVisible(false);
		
			
			//cal
			var cal_tag=new Button(this.main,11,TAG_CAL,"#tag/CAL.png");
			cal_tag.setPosition(cc.p(this.main.width*0.63, this.main.height*0.807));
			cal_tag.setVisible(false);
		    
			var cal_tag2=new Button(this.main,11,TAG_CAL2,"#tag/CAL2.png");
			cal_tag2.setPosition(cc.p(this.main.width*0.63, this.main.height*0.807));
			cal_tag2.setVisible(false);
			
			var cal_tag3=new Button(this.main,11,TAG_CAL3,"#tag/CAL3.png");
			cal_tag3.setPosition(cc.p(this.main.width*0.63, this.main.height*0.807));
			cal_tag3.setVisible(false);
			
			//1
			var one=new Button(this.main,11,TAG_ONE,"#tag/ONE.png");
			one.setPosition(cc.p(this.main.width*0.63, this.main.height*0.837));
			one.setVisible(false);
			//2
			var two=new Button(this.main,11,TAG_TWO,"#tag/TWO.png");
			two.setPosition(cc.p(this.main.width*0.63, this.main.height*0.837));
			two.setVisible(false);
			//3
			var three=new Button(this.main,11,TAG_THREE,"#tag/THREE.png");
			three.setPosition(cc.p(this.main.width*0.63, this.main.height*0.837));
			three.setVisible(false);
			//cond
			var cond=new Button(this.main,11,TAG_COND,"#tag/COND.png");
			cond.setPosition(cc.p(this.main.width*0.5,this.main.height*0.808));
			cond.setVisible(false);
			//time
			var time=new Button(this.main,11,TAG_TIME,"#tag/time.png");
			time.setPosition(cc.p(this.main.width*0.64, this.main.height*0.805));
			time.setVisible(false);
			//数据
			var num=new Button(this.main,11,TAG_NUM,"#tag/num1.png");
			num.setPosition(cc.p(this.main.width*0.515, this.main.height*0.732));
			num.setVisible(false);
			var num8=new Button(this.main,11,TAG_NUM,"#tag/num8.png");
			num8.setPosition(cc.p(this.main.width*0.515, this.main.height*0.732));
			num8.setVisible(false);
			//笑脸
			var smile=new Button(this.main,11,TAG_SMILE,"#tag/smile.png");
			smile.setPosition(cc.p(this.main.width*0.38, this.main.height*0.68));
			smile.setVisible(false);
			//温度
			var Temperature=new Button(this.main,11,TAG_TEMPERATURE,"#tag/25.0.png");
			Temperature.setPosition(cc.p(this.main.width*0.565, this.main.height*0.68));
			Temperature.setVisible(false);
			//单位
			var us=new Button(this.main,11,TAG_US,"#tag/us.png");
			us.setPosition(cc.p(this.main.width*0.635, this.main.height*0.72));
			us.setVisible(false);
			//mtc
			var mtc=new Button(this.main,11,TAG_MTC,"#tag/MTC.png");
			mtc.setPosition(cc.p(this.main.width*0.64, this.main.height*0.68));
			mtc.setVisible(false);
			
			//ph
			var ph=new Button(this.main,11,TAG_PH,"#tag/ph.png");
			ph.setPosition(cc.p(this.main.width*0.38, this.main.height*0.8));
			ph.setVisible(false);
			//atc
			var atc=new Button(this.main,11,TAG_ATC,"#tag/ATC.png");
			atc.setPosition(cc.p(this.main.width*0.64, this.main.height*0.68));
			atc.setVisible(false);
			//M
			var M=new Button(this.main,11,TAG_M,"#tag/M.png");
			M.setPosition(cc.p(this.main.width*0.38, this.main.height*0.64));
			M.setVisible(false);
			//L
			var L=new Button(this.main,11,TAG_L,"#tag/L.png");
			L.setPosition(cc.p(this.main.width*0.34, this.main.height*0.64));
			L.setVisible(false);
			//H
			var H=new Button(this.main,11,TAG_H,"#tag/H.png");
			H.setPosition(cc.p(this.main.width*0.42, this.main.height*0.64));
			H.setVisible(false);
			//1M
			var M1=new Button(this.main,11,TAG_M1,"#tag/1m+.png");
			M1.setPosition(cc.p(this.main.width*0.635, this.main.height*0.64));
			M1.setVisible(false);
			//RES
			var res=new Button(this.main,11,TAG_RES,"#tag/RES.png");
			res.setPosition(cc.p(this.main.width*0.465,this.main.height*0.8));
			res.setVisible(false);
			//TDS
			var tds=new Button(this.main,11,TAG_TDS,"#tag/TDS.png");
			tds.setPosition(cc.p(this.main.width*0.5,this.main.height*0.8));
			tds.setVisible(false);
			//SAL
			var sal=new Button(this.main,11,TAG_SAL,"#tag/SAL.png");
			sal.setPosition(cc.p(this.main.width*0.535,this.main.height*0.8));
			sal.setVisible(false);
			
			var ppt=new Button(this.main,11,TAG_PPT,"#tag/PPT.png");
			ppt.setPosition(cc.p(this.main.width*0.45, this.main.height*0.68));
			ppt.setVisible(false);
			
			var mc=new Button(this.main,11,TAG_MC,"#tag/mc.png");
			mc.setPosition(cc.p(this.main.width*0.635, this.main.height*0.72));
			mc.setVisible(false);
			
		},
		callback:function(pSender){
			var action=gg.flow.flow.action;
			var instrument_1=ll.run.getChildByTag(TAG_MP_INSTRUMENT);
			var main=instrument_1.getChildByTag(TAG_MAIN);
			var instrument=main.getChildByTag(TAG_INSTRUMENT);
			var onOroff=main.getChildByTag(TAG_BUTTON_ONOROFF);
			var instrument1=main.getChildByTag(TAG_INSTRUMENT_BACK);
			
			var socket=main.getChildByTag(TAG_SOCKET);
			var socket1=main.getChildByTag(TAG_SOCKET1);
			var socket2=main.getChildByTag(TAG_SOCKET2);
			
			var instrument_back2=main.getChildByTag(TAG_INSTRUMENT_BACK2);
			var powerLine=main.getChildByTag(TAG_POWERLINE_HEAD);
			
			
			var unit=main.getChildByTag(TAG_BUTTON_UNIT);
			var cal=main.getChildByTag(TAG_BUTTON_CAL);
			
			var electrode_line=main.getChildByTag(TAG_ELECTRODE_HEAD);
			var electrode_line1=main.getChildByTag(TAG_ELECTRODE_HEAD1);
			var instrument_back1=main.getChildByTag(TAG_INSTRUMENT_BACK1);
			var cal_tag=main.getChildByTag(TAG_CAL);
			var cal_tag2=main.getChildByTag(TAG_CAL2);
			var cal_tag3=main.getChildByTag(TAG_CAL3);
			
			var cond=main.getChildByTag(TAG_COND);
			var time=main.getChildByTag(TAG_TIME);
			var one=main.getChildByTag(TAG_ONE);
			var two=main.getChildByTag(TAG_TWO);
			var three=main.getChildByTag(TAG_THREE);
			

			var num=main.getChildByTag(TAG_NUM);
			var num8=main.getChildByTag(TAG_NUM8);
			var smile=main.getChildByTag(TAG_SMILE);
			var temperature=main.getChildByTag(TAG_TEMPERATURE);
			var us=main.getChildByTag(TAG_US);
			var mtc=main.getChildByTag(TAG_MTC);
			var m=main.getChildByTag(TAG_M);
			
			var H=main.getChildByTag(TAG_H);
			var L=main.getChildByTag(TAG_L);
			
			var m1=main.getChildByTag(TAG_M1);
			var res=main.getChildByTag(TAG_RES);
			var tds=main.getChildByTag(TAG_TDS);
			var sal=main.getChildByTag(TAG_SAL);
			var atc=main.getChildByTag(TAG_ATC);
			var ppt=main.getChildByTag(TAG_PPT);
			var mc=main.getChildByTag(TAG_MC);
			var ph=main.getChildByTag(TAG_PH);
			switch(pSender.getTag()){
			case TAG_BUTTON_ONOROFF:
				gg.flow.next();
				instrument.setSpriteFrame("equitment/instrument2.png");
			    electrode_line.setVisible(false);
			    ph.setVisible(true);
				time.setVisible(true);
				num.setVisible(true);
				us.setVisible(true);
				smile.setVisible(true);
				temperature.setVisible(true);
				ph.setVisible(true);
				m1.setVisible(true);
				cal.setVisible(true);
				mtc.setVisible(true);
				var instrument1=ll.run.getChildByTag(TAG_INSTRUMENT);
				instrument1.setSpriteFrame("equitment/Instrument_1.png");
				unit.setVisible(true);
				break;
			case TAG_BUTTON_UNIT:
				gg.flow.next();
				if(action==ACTION_DO1){
					cond.setVisible(false);
					//res.setVisible(true);
					mc.setVisible(true);
					m.setVisible(false);
					us.setVisible(false);
					ph.setVisible(true);
				}else if(action==ACTION_DO2){
					res.setVisible(false);
					mc.setVisible(false);
					tds.setVisible(true);
				}else if(action==ACTION_DO3){
					tds.setVisible(false);
					sal.setVisible(true);
					ppt.setVisible(true);
				}else if(action==ACTION_DO4){
					ppt.setVisible(false);
					sal.setVisible(false);
					cond.setVisible(true);
					us.setVisible(true);
				}
				break;
			case TAG_POWERLINE_HEAD:
				var move=cc.moveTo(1,cc.p(main.width*0.69, main.height*0.41));	
				var move1=cc.moveTo(1,cc.p(gg.c_width*0.83,gg.c_height*0.9));
				pSender.runAction(cc.sequence(cc.spawn(move,cc.callFunc(function() {
					var powerline=ll.run.getChildByTag(TAG_POWERLINE);
					powerline.runAction(move1);
				}, this)),cc.callFunc(function(){
					gg.flow.next();
				},this)));
				break;
		
			case TAG_BUTTON_CAL:
				if(action==ACTION_DO2){
					smile.setVisible(false);
					temperature.setVisible(false);
					mtc.setVisible(false);
					var beaker=ll.run.getChildByTag(TAG_BEAKER1);
					beaker.setVisible(false);
					cal_tag.setVisible(false);
					pSender.runAction(cc.sequence(cc.callFunc(function() {
						num.setSpriteFrame("tag/num8.png");	
						num.runAction(cc.sequence(cc.fadeIn(0.5),cc.fadeOut(0.5)).repeat(3));
					},this),cc.delayTime(3),cc.callFunc(function() {
						num.runAction(cc.fadeIn(0.5));;
						num.setSpriteFrame("tag/END.png");
						us.setVisible(false);
					},this),cc.delayTime(2),cc.callFunc(function(){
						num.setSpriteFrame("tag/num8.png");
						us.setVisible(true);
						m.setVisible(true);
						
						var fadeout=cc.fadeOut(0.5);
						var fadein=cc.fadeIn(0.5)
						cal_tag2.setVisible(true);
						cal_tag2.runAction(cc.repeatForever(cc.sequence(fadeout,fadein)));
					}, this),cc.callFunc(function() {
						gg.flow.next();
					}, this)));
				}
				else if(action==ACTION_DO9){
					smile.setVisible(false);
					temperature.setVisible(false);
					mtc.setVisible(false);
					cal_tag2.setVisible(false);
					
					var beaker=ll.run.getChildByTag(TAG_BEAKER4);
					beaker.setVisible(false);
					cal_tag.setVisible(false);
					pSender.runAction(cc.sequence(cc.callFunc(function() {
						
						num.setSpriteFrame("tag/num15.png");	
						num.runAction(cc.sequence(cc.fadeIn(0.5),cc.fadeOut(0.5)).repeat(3));
					},this),cc.delayTime(3),cc.callFunc(function() {
						num.runAction(cc.fadeIn(0.5));;
						num.setSpriteFrame("tag/END.png");
						us.setVisible(false);
					},this),cc.delayTime(2),cc.callFunc(function(){
						num.setSpriteFrame("tag/num15.png");
						us.setVisible(true);
						m.setVisible(true);
						var fadeout=cc.fadeOut(0.5);
						var fadein=cc.fadeIn(0.5)
						cal_tag3.setVisible(true);
						cal_tag3.runAction(cc.repeatForever(cc.sequence(fadeout,fadein)));
					}, this),cc.callFunc(function() {
						gg.flow.next();
					}, this)));
				}else if(action==ACTION_DO11){
					smile.setVisible(false);					
					cal_tag3.setVisible(false);
					temperature.setVisible(false);
					mtc.setVisible(false);
					var beaker=ll.run.getChildByTag(TAG_BEAKER6);
					beaker.setVisible(false);
					
					m.setVisible(true);
					L.setVisible(true);
					H.setVisible(true);
					
					pSender.runAction(cc.sequence(cc.callFunc(function() {
						num.setSpriteFrame("tag/num19.png");	
						num.runAction(cc.sequence(cc.fadeIn(0.5),cc.fadeOut(0.5)).repeat(3));
					},this),cc.delayTime(3),cc.callFunc(function() {
						num.runAction(cc.fadeIn(0.5));;
						num.setSpriteFrame("tag/END.png");
						us.setVisible(false);
					},this),cc.delayTime(2),cc.callFunc(function(){
						num.setSpriteFrame("tag/num19.png");
						us.setVisible(true);	
						
					}, this),cc.callFunc(function() {
						
						gg.flow.next();
					}, this)));
				}
				else if(action==ACTION_DO1){
					gg.flow.next();
				//	one.setVisible(true);
					temperature.setSpriteFrame("tag/23.3.png");
					time.setVisible(false);
					var fadeout=cc.fadeOut(0.5);
					var fadein=cc.fadeIn(0.5)
					cal_tag.setVisible(true);
					cal_tag.runAction(cc.repeatForever(cc.sequence(fadeout,fadein)));
				}
				break;
			case TAG_ELECTRODE_HEAD:
				var move=cc.moveTo(1,cc.p(main.width*0.46, main.height*0.365));	
				var move1=cc.moveTo(1,cc.p(gg.c_width*0.83,gg.c_height*0.9));
				pSender.runAction(cc.sequence(move,cc.callFunc(function() {
					electrode_line.setVisible(true);
					powerLine.setVisible(true);
					instrument_back1.setVisible(true);
					instrument_back2.setVisible(true);
					instrument1.setVisible(true);
					instrument.setVisible(false);
				    //socket.setVisible(true);
					//socket1.setVisible(true);
					//socket2.setVisible(true);
					onOroff.setVisible(false);
				}, this),cc.callFunc(function(){
					gg.flow.next();
				},this)));
				break;
			case TAG_ELECTRODE_HEAD1:
				var move=cc.moveTo(1,cc.p(main.width*0.42, main.height*0.35));	
				var move1=cc.moveTo(1,cc.p(gg.c_width*0.83,gg.c_height*0.9));
				pSender.runAction(cc.sequence(move,cc.callFunc(function() {
					electrode_line.setVisible(false);
					electrode_line1.setVisible(false);
					powerLine.setVisible(false);
					instrument_back1.setVisible(false);
					instrument_back2.setVisible(false);
					
					instrument1.setVisible(false);
					instrument.setVisible(true);
					socket.setVisible(false);
					socket1.setVisible(false);
					socket2.setVisible(false);
					onOroff.setVisible(true);
				}, this),cc.callFunc(function(){
					gg.flow.next();
				},this)));
				break;
			default:
				break;
			}
		}
});